package org.apache.rocketmq.console.controller;

import org.apache.rocketmq.console.model.Account;
import org.apache.rocketmq.console.service.AccountlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author caiwl
 * @date 2021/6/1 15:35
 */
@Controller
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private AccountlService accountlService;

    @GetMapping("/list.query")
    @ResponseBody
    public Object list() {
        return accountlService.list();
    }

    @PostMapping("/createOrUpdate.do")
    @ResponseBody
    public Object createOrUpdate(@RequestBody Account account) {
        return accountlService.createOrUpdateAccount(account);
    }

    @PostMapping("/deleteAccount.do")
    @ResponseBody
    public Object delete(@RequestParam String brokerAddr, @RequestParam String accessKey) {
        return accountlService.deleteAccount(brokerAddr, accessKey);
    }
}
